
require("./requires");
var http_service = require("./http_service");
var socket_service = require("./socket_service");


var log4js = require('log4js');
var path = require('path');
var logConfig = require('./config/log4js')
log4js.configure(logConfig(path.dirname(__dirname)));
var log = log4js.getLogger("majiangServer");

//从配置文件获取服务器信息
var configs = require(process.argv[2]);
var config = configs.game_server();

var db = require('../utils/db');
db.init(configs.mysql());
// 初始化redis
var redis = require('../utils/redis');
redis.init(configs.redis());

//开启HTTP服务
http_service.start(config);

//开启外网SOCKET服务
socket_service.start(config);

// process.on('uncaughtException', function (err) {
// 　　log.info('Caught exception: ' + err);
// });

function uncaughtExceptionHandler(err){
    if(err && err.code == 'ECONNREFUSED'){
        //do someting
        
    }else{
        process.exit(1);
    }
}
process.on('uncaughtException', uncaughtExceptionHandler);